import 'package:flutter/material.dart';
import 'package:hbtrans_flutter/apis.dart';
import 'package:hbtrans_flutter/beans/orderlist_bean.dart';
import 'package:hbtrans_flutter/utils/mydio.dart';
import 'package:hbtrans_flutter/view/orderList.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SignOrder extends StatefulWidget {
  @override
  _SignOrderState createState() => _SignOrderState();
}

class _SignOrderState extends State<SignOrder> with SingleTickerProviderStateMixin{


  TabController _tabController;
  var brotherCategory = ['全部', '待付款', '已付款'];
  var titleIndex = ['', '0', '1'];
  var currentIndex = 0;
  var userId = '';


  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(
        initialIndex: currentIndex, length: brotherCategory.length, vsync: this)
      ..addListener(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          title: Text('我的订单'),
          centerTitle: true,
          bottom: PreferredSize(
              child: Material(
                color: Colors.white,
                child: TabBar(
                  isScrollable: false,
                  controller: _tabController,
                  tabs: getTabBars(),
                  indicatorSize:TabBarIndicatorSize.label,
                  indicatorColor: Color(0xff23AFDC),
                  unselectedLabelColor: Colors.black,
                  labelColor: Color(0xff23AFDC),),
              ),
              preferredSize: Size.fromHeight(48))

      ),
      body: TabBarView(
        children: getTabBarViews(),
        controller: _tabController,
      ),
    );
  }

  List<Widget> getTabBars() {
    List<Widget> tabBar = List();
    for (int i = 0; i < brotherCategory.length; i++) {
      tabBar.add(Tab(text: brotherCategory[i]));
    }
    return tabBar;
  }

  List<Widget> getTabBarViews() {
    List<Widget> tabBarView = List();
    for (var i = 0; i < titleIndex.length; i++) {
      tabBarView.add(OrderList(userId,titleIndex[i]));
    }
    return tabBarView;
  }

}
